package custom.jdbc.test;

import org.apache.ibatis.jdbc.SQL;

import java.sql.*;

public class JdbcTestA {
	private static Connection conn = null;
	private static PreparedStatement prep = null;

	static {
		try {
			Class.forName("com.mysql.jdbc.Driver");
			conn = DriverManager.getConnection("jdbc:mysql://localhost:3306/mybatis0506?useUnicode=true&characterEncoding=UTF-8&allowMultiQueries=true&useSSL=false", "root", "root");

		} catch (Exception e) {
			e.printStackTrace();
		}
	}
	public static void main(String[] args) throws ClassNotFoundException, SQLException {
		JdbcTestA jdbcTestA = new JdbcTestA();
		jdbcTestA.getSchool();

	}

	public void getSchool() throws SQLException {
		prep = conn.prepareStatement("select * from t_school where school_name = ?");
		prep.setString(1,"厦门市第三中学");
		ResultSet rs = prep.executeQuery();
		while (rs.next()){
			String id = rs.getString("id");
			String schoolName = rs.getString("school_name");
			String ofAredId = rs.getString("of_area_id");
			String address = rs.getString("address");
			System.out.println(schoolName+address);
		}
	}


}

